
/**
 * 拦截未登录用户
 */
 module.exports = (filterArr = []) => {
    return async (ctx, next)=>{
        if(!filterArr.includes(ctx.__req.method)){
            let data = ctx.request.headers;
            try {
                validates('index','token').check(data);
            } catch (error) {
                ctx._throw(7500,error.message);
            }
            let userInfo = fun.getToken(String(data.authorization).split(' ')[1]);
            if(!userInfo){
                ctx._throw(7500,'登录已过期,请重新登录!');
            }
            ctx.__userinfo = userInfo;
        }
        await next();//放行
    };
};